package com.fc.mall.kdniao.exception;

import java.text.MessageFormat;

public class KDNiaoException extends RuntimeException {

    private int code;

    public KDNiaoException(KDNiaoErrorCode errorCode) {
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
    }

    public KDNiaoException(KDNiaoErrorCode errorCode, String... args) {
        super(MessageFormat.format(errorCode.getMsg(), args));
        this.code = errorCode.getCode();
    }

    public KDNiaoException(KDNiaoErrorCode errorCode, Throwable cause) {
        super(errorCode.getMsg(), cause);
        this.code = errorCode.getCode();
    }

    public KDNiaoException(int code, String message) {
        super(message);
        this.code = code;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
